<template>
	<div>
		<el-tabs v-model="activeName">
			<el-tab-pane v-for="(item, index) in tabsList" :key="index" :label="item.label" :name="item.value" @tab-click="handleTabChange"> </el-tab-pane>

			<div class="content-card">
				<html-label :title="activeLabelTitle"> </html-label>

				<component
					v-if="!loading"
					class="pd10"
					:is="whickComm[activeName]"
					:isWithAuth="0"
					:soleKey="`dpServiceFacility-${nowRowData.soleValue}`"
					@refresh="handleRefresh"
					:nowRowData="nowRowData"
				></component>
			</div>
		</el-tabs>
	</div>
</template>

<script setup lang="ts">

import Extend from '@/views/datacenter/basicData/serviceFacility/components/Archives/Extend/index.vue'
import BaseDetail from './BaseDetail/index.vue'
import ObjectOther from '@/views/datacenter/basicData/serviceFacility/components/Archives/ObjectOther/index.vue'
import OperationsRecords1 from '@/views/datacenter/basicData/serviceFacility/components/Archives/OperationsRecords1/index.vue'
import apiMod from '@/apiMod'
import { useCommonStore } from '@/stores/common'

const { setLoading } = useCommonStore()
const whickComm = {
	BaseDetail,
	Extend,
	ObjectOther,
	OperationsRecords1,
}
type Props = {
	nowRowData?: any
}
const props = withDefaults(defineProps<Props>(), {})
const emit = defineEmits(['refresh', 'rechange'])
const loading = ref(false)
const activeLabelTitle = ref('基础信息')

const tabsList: any = [
	{ label: '基础信息', value: 'BaseDetail' },
	{ label: '扩展信息', value: 'Extend' },
	{ label: '其他信息', value: 'ObjectOther' },
	{ label: '运营记录', value: 'OperationsRecords1' },
]
const activeName = ref('BaseDetail')
let nowData = ref({})
provide('nowRowData', nowData)
const getInitData = () => {
	loading.value = true
	setLoading()
	apiMod
		.view_dpServiceFacilityFile_all({soleValue:props.nowRowData.soleValue})
		.then((res) => {
      const data = res.data || {}
			loading.value = false
			nowData.value = {
        ...data.dpServiceFacilityFile||{},
        dpServiceFacilityExtend:data.dpServiceFacilityExtendFile||{},
        dpServiceFacilityOther:data.dpServiceFacilityOtherFile||{},
        dpSenileProductsList:data.dpSenileProductsFileList||[],
        dpFacilityEquipmentList:data.dpFacilityEquipmentFileList||[],
      }
			setLoading()
		})
		.catch((err) => {
			loading.value = false
		})
}

const handleTabChange = (tab) => {
	activeLabelTitle.value = tab.props.label
}

const handleRefresh = () => {
	emit('refresh')
}
onMounted(() => {
	getInitData()
})
</script>

<style scoped></style>
